﻿using ERP.Common.Results;
using ERP.Team.ProductionSystem;
using ERP.ERPSystem.ProductionSystem.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;

namespace ERP.ERPSystem.ProductionSystem
{
    public interface ICustomerOrderServices:IApplicationService
    {
        /// <summary>
        /// 获取产品分类+分页
        /// </summary>
        /// <returns></returns>
        Task<APIPaging<ProductInfoRelationModel>> GetProductInfoRelation(string? code, string? Name, int page = 1, int limit = 10);

        /// <summary>
        /// 添加客户订单
        /// </summary>
        /// <param name="customerOrderDto">客户订单信息</param>
        /// <returns>订单ID</returns>
        Task<int> AddCustomerOrder(CustomerOrderDto customerOrderDto);

        /// <summary>
        /// 分页查询客户订单列表
        /// </summary>
        /// <param name="queryDto">查询条件</param>
        /// <returns>分页订单列表</returns>
        Task<APIPaging<CustomerOrderModel>> GetCustomerOrderList(CustomerOrderQueryDto queryDto);

        /// <summary>
        /// 根据ID获取客户订单详情
        /// </summary>
        /// <param name="id">订单ID</param>
        /// <returns>订单详情</returns>
        Task<CustomerOrderModel> GetCustomerOrderById(int id);

        /// <summary>
        /// 更新客户订单
        /// </summary>
        /// <param name="customerOrderDto">客户订单信息</param>
        /// <returns>更新结果</returns>
        Task<bool> UpdateCustomerOrder(CustomerOrderDto customerOrderDto);

        /// <summary>
        /// 批量删除客户订单
        /// </summary>
        /// <param name="ids">订单ID数组</param>
        /// <returns>删除结果</returns>
        Task<bool> DeleteCustomerOrders(int[] ids);

        /// <summary>
        /// 分页查询物料产品列表
        /// </summary>
        /// <param name="materielCode">物料编码</param>
        /// <param name="materielName">物料名称</param>
        /// <param name="page">当前页</param>
        /// <param name="limit">每页数量</param>
        /// <returns>分页物料列表</returns>
        Task<APIPaging<MaterialproductModel>> GetMaterialProductList(string? materielCode, string? materielName, int page = 1, int limit = 10);

        /// <summary>
        /// 根据订单ID获取物料需求列表
        /// </summary>
        /// <param name="customerOrderId">客户订单ID</param>
        /// <returns>物料需求列表</returns>
        Task<List<MaterialRequirementDto>> GetMaterialRequirementsByOrderId(int customerOrderId);

        /// <summary>
        /// 带事务的更新客户订单和物料需求
        /// </summary>
        /// <param name="customerOrderDto">客户订单信息</param>
        /// <param name="materialRequirements">物料需求列表</param>
        /// <returns>更新结果</returns>
        Task<bool> UpdateCustomerOrderWithMaterialRequirements(CustomerOrderDto customerOrderDto, List<MaterialRequirementDto> materialRequirements);
    }
}
